package com.heima.article.controller;

import com.heima.article.service.ApArticleService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.article.dto.ArticleHomeDTO;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: zhk
 * @since: 2025/6/26
 */
@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController {
    @Autowired
    private ApArticleService articleHomeService;
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDTO articleHomeDTO){
         List<ApArticle> list = articleHomeService.load(articleHomeDTO, ArticleConstants.LOADTYPE_LOAD_MORE);
         return ResponseResult.okResult(list);
    }
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDTO articleHomeDTO){
        List<ApArticle> list = articleHomeService.load(articleHomeDTO, ArticleConstants.LOADTYPE_LOAD_MORE);
        return ResponseResult.okResult(list);
    }
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDTO articleHomeDTO){
        List<ApArticle> list = articleHomeService.load(articleHomeDTO, ArticleConstants.LOADTYPE_LOAD_NEW);
        return ResponseResult.okResult(list);
    }

}
